package com.wzu.springbootcrud2.service;

import com.wzu.springbootcrud2.dao.Maildao;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
public class AsynService implements Maildao {
    @Autowired
    JavaMailSender javaMailSender;

    @Async
    public void sendEmail() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("dcl2362702988@163.com");
        message.setTo("2362702988@qq.com");
        //18211164205董成龙
        message.setSubject("这是一个测试邮件");
        message.setText("这是一个测试邮件的内容");
        try {
            javaMailSender.send(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
